home *** CD-ROM | disk | FTP | other *** search
/ PC Home 49 / PC_Home_Issue_49.iso / lldemo / lldemo.shr / ROSETTA.EXE / ROSETTA.DXR / 00570_login handling scripts.ls < prev    next >
Encoding:
Text File  |  1996-06-24  |  5.5 KB  |  208 lines

  1. on legalLogin
  2.   global gStuList, gStuLogin, gStuListPath
  3.   set p to getPos(gStuList, gStuLogin)
  4.   if p = 0 then
  5.     return EMPTY
  6.   else
  7.     return getAt(gStuListPath, p)
  8.   end if
  9. end
  10.  
  11. on startGuest
  12.   global gStuLogin, gTest, gTimer, gBlindfold, gStuInfo
  13.   set gStuLogin to "GUEST"
  14.   set gTest to 0
  15.   set gTimer to 0
  16.   set gBlindfold to 0
  17.   set gStuInfo to [#name: "GUEST"]
  18.   set the keyDownScript to "handleKey"
  19.   readprefs()
  20.   updateStage()
  21.   goChangeMeta("selectStart")
  22. end
  23.  
  24. on checkUser
  25.   global gStuLogin, gSMSStuPath
  26.   set gStuLogin to field "Login Name"
  27.   set gStuLogin to upperCase(gStuLogin)
  28.   set c to the number of chars in gStuLogin
  29.   if char c of gStuLogin = " " then
  30.     delete char c of gStuLogin
  31.   end if
  32.   if char 1 of gStuLogin = " " then
  33.     delete char 1 of gStuLogin
  34.   end if
  35.   if gStuLogin = "GUEST" then
  36.     startGuest()
  37.   else
  38.     set path to legalLogin()
  39.     if path <> EMPTY then
  40.       set the keyDownScript to "handleKey"
  41.       updateStage()
  42.       set gSMSStuPath to path & gStuLogin
  43.       loginLoad(gSMSStuPath)
  44.     else
  45.       alert(field "No Record")
  46.       unhighlight(13)
  47.     end if
  48.   end if
  49. end
  50.  
  51. on loginLoad thePath
  52.   global gTest, gTimer
  53.   set err to loginStudent(thePath)
  54.   if err <> #NOERR then
  55.     if err = #ERRSTUINFO then
  56.       alert("Error in loading student information")
  57.       loadServerLists()
  58.     else
  59.       if err = #ERRBADPASS then
  60.         alert("Incorrect Password. Please re-enter.")
  61.       else
  62.         if err = #ERRORDER then
  63.           alert("Error in loading chapter order")
  64.         else
  65.           if err = #ERRMETHOD then
  66.             alert("Error in loading tutorial. See your instructor to change your tutorial setting.")
  67.           end if
  68.         end if
  69.       end if
  70.     end if
  71.     goChangeMeta("login")
  72.   else
  73.     clearScore()
  74.     set gTest to 0
  75.     set gTimer to 0
  76.     set ret to doMode(#sms, "skip")
  77.     if ret = #done then
  78.       alert("You have completed the required assignment. See your instructor for more or login as GUEST.")
  79.       goChangeMeta("login")
  80.     else
  81.       if ret = #error then
  82.         goChangeMeta("login")
  83.       end if
  84.     end if
  85.   end if
  86. end
  87.  
  88. on loginStudent thePath
  89.   global gStuInfo, gPassword
  90.   if not loadStuInfo(thePath) then
  91.     return #ERRSTUINFO
  92.   end if
  93.   if smsPWcheck(gPassword, getaProp(gStuInfo, #PASSWORD)) = 0 then
  94.     return #ERRBADPASS
  95.   end if
  96.   if not loadOrder() then
  97.     return #ERRORDER
  98.   end if
  99.   if not loadMethod(thePath) then
  100.     return #ERRMETHOD
  101.   end if
  102.   return #NOERR
  103. end
  104.  
  105. on handleKeyLoginID
  106.   if (the key = RETURN) or (the key = ENTER) then
  107.     highlight(13)
  108.     updateStage()
  109.     dontPassEvent()
  110.     checkUser()
  111.   else
  112.     if the key = TAB then
  113.       dontPassEvent()
  114.       set the keyDownScript to "handleKeyLoginPass"
  115.       go("Password field")
  116.     end if
  117.   end if
  118. end
  119.  
  120. on handleKeyLoginPass
  121.   global gPassword
  122.   if (the key = RETURN) or (the key = ENTER) then
  123.     highlight(13)
  124.     updateStage()
  125.     dontPassEvent()
  126.     checkUser()
  127.   else
  128.     if the key = TAB then
  129.       set the keyDownScript to "handleKeyLoginID"
  130.       go("ID field")
  131.     else
  132.       if the selStart <> the selEnd then
  133.         delete char the selStart + 1 to the selEnd of gPassword
  134.         delete char the selStart + 1 to the selEnd of field "password"
  135.         moveCarat(the selStart)
  136.       end if
  137.       set k to charToNum(the key)
  138.       if k = 8 then
  139.         if the selStart <> 0 then
  140.           set curs to selStart
  141.           delete char the selStart of gPassword
  142.           delete char the selStart of field "password"
  143.           moveCarat(curs - 1)
  144.         end if
  145.       else
  146.         if k = 127 then
  147.           if the selStart <> the number of chars in gPassword then
  148.             delete char the selStart + 1 of gPassword
  149.             delete char the selStart + 1 of field "password"
  150.           end if
  151.         else
  152.           if k = 28 then
  153.             if the selStart <> 0 then
  154.               moveCarat(the selStart - 1)
  155.             end if
  156.           else
  157.             if k = 29 then
  158.               if the selStart <> the number of chars in gPassword then
  159.                 moveCarat(the selStart + 1)
  160.               end if
  161.             else
  162.               if k = 30 then
  163.               else
  164.                 if k = 31 then
  165.                 else
  166.                   if k = 1 then
  167.                     moveCarat(0)
  168.                   else
  169.                     if k = 4 then
  170.                       moveCarat(the number of chars in gPassword)
  171.                     else
  172.                       if k = 11 then
  173.                       else
  174.                         if k = 12 then
  175.                         else
  176.                           if the selStart = 0 then
  177.                             set gPassword to the key & gPassword
  178.                           else
  179.                             if the selStart <> the number of chars in gPassword then
  180.                               set gPassword to char 1 to the selStart of gPassword & the key & char the selStart + 1 to the number of chars in gPassword of gPassword
  181.                             else
  182.                               put the key after gPassword
  183.                             end if
  184.                           end if
  185.                           put "*" after field "password"
  186.                           moveCarat(the selStart + 1)
  187.                         end if
  188.                       end if
  189.                     end if
  190.                   end if
  191.                 end if
  192.               end if
  193.             end if
  194.           end if
  195.         end if
  196.       end if
  197.     end if
  198.   end if
  199.   dontPassEvent()
  200. end
  201.  
  202. on moveCarat x
  203.   set the selStart to x
  204.   set the selEnd to x
  205.   set the selStart to x
  206.   set the selEnd to x
  207. end
  208.